package com.wva.common.utils;

import com.j256.simplemagic.ContentInfo;
import com.j256.simplemagic.ContentInfoUtil;

/**
 * @Author: hong
 * @Date: 2025/2/8 18:31:32
 */
public class FileUtils {
    /**
     * 输入.mp4返回video/mp4
     * @param extension
     * @return
     */
    public static String getMimeByExtension(String extension) {
        ContentInfo extensionMatch = ContentInfoUtil.findExtensionMatch(extension);
        if (extensionMatch == null) {
            return ContentInfoUtil.findExtensionMatch("").getMimeType();
        }
        return extensionMatch.getMimeType();
    }
}
